package com.honey.mybatis.generator.model;

import com.honey.compilation.java.AbstractJavaCompilation;
import com.honey.compilation.java.Field;
import com.honey.compilation.java.InnerEnum;
import com.honey.compilation.java.Method;
import com.honey.core.compiler.CompilationException;
import com.honey.core.dbmapping.introspect.IntrospectSchema;
import com.honey.core.dbmapping.introspect.IntrospectSchemaColumn;
import com.honey.mybatis.generator.AbstractProduceJavaCompilation;
import com.honey.mybatis.generator.MybatisPlugin;
import com.honey.mybatis.generator.model.field.ValueField;
import com.honey.mybatis.generator.model.method.EnumConstructorMethod;
import com.honey.mybatis.generator.model.method.EnumToStringMethod;

public class ProduceTableCloumnEnum  extends AbstractProduceJavaCompilation {

	private InnerEnum innerEnum = null; 
	
	public ProduceTableCloumnEnum(MybatisPlugin mybatisPlugin,
			IntrospectSchema introspectSchema,
			IntrospectSchemaColumn introspectSchemaColumn) {
		super(mybatisPlugin, introspectSchema, introspectSchemaColumn);
	}

	@Override
	public AbstractJavaCompilation produceCompilation() throws CompilationException {
		innerEnum =(InnerEnum) new TableColumnEnum(mybatisPlugin, introspectSchema, introspectSchemaColumn).createJavaCompilation();
		return innerEnum;
	}

	@Override
	public Field[] produceFields() throws CompilationException {
		Field[]  answer = new Field[] {
				new ValueField().createField(),
		};
		return answer;
	}

	@Override
	public Method[] produceMethods() throws CompilationException {
		Method[] answer = new Method[]{
			new EnumConstructorMethod(innerEnum, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod(),
			new EnumToStringMethod(innerEnum, mybatisPlugin, introspectSchema, introspectSchemaColumn).createMethod(),
		};
		return answer;
	}
}
